package com.myappengine.tags;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

@SuppressWarnings("serial")
public class KeyToStringTag extends TagSupport {
	
	private Key key;
	private String var;
	
	public void setKey(Key key) {
		this.key = key;
	}
	
	public void setVar(String var) {
		this.var = var;
	}

	@Override
	public int doStartTag() throws JspException {
		pageContext.setAttribute(var, KeyFactory.keyToString(key));
		return SKIP_BODY;
	}
}
